public class MyLinkedList implements IList{
//    实现无头双向链表
    static class ListNode{
        public int val;
        public ListNode next;
        public ListNode prev;

        public ListNode (int val){
            this.val=val;
        }
    }
    public ListNode head;
    public ListNode last;//尾节点
//    使用尾节点可以方便地在链表的尾部插入新节点
    @Override
    public void addFirst(int data) {
        ListNode node=new ListNode(data);
        if(head==null){
            head=node;
            last=node;
        }else{
            node.next=head;
            head.prev=node;
            head=node;
        }
    }

    @Override
    public void addLast(int data) {
        ListNode node=new ListNode(data);
        if(head==null){
            head=node;
            last=node;
        }else{
            last.next=node;
            node.prev=last;
            last=node;
        }
    }

    @Override
    public void addIndex(int index, int data) {
        if (head==null || head.next==null){

        }
    }

    @Override
    public boolean contains(int key) {
        return false;
    }

    @Override
    public void remove(int key) {


    }

    @Override
    public void removeAllKey(int key) {

    }

    @Override
    public int size() {
        return 0;
    }

    @Override
    public void clear() {

    }

    @Override
    public void display() {

    }
}
